import http from '@/utils/http/axios'
import { ContentTypeEnum } from '@/enums/httpEnum'

enum Api {
  roleList = '/role/rolelist',
  userList = '/user/list',
  userDelete = '/user/delete',
  userCreate = '/user/add',
  userUpdate = '/user/update',
  userUpdatePassword = '/user/updatepwd'
}

/**
 * @description: 更新用户策略
 */
export function userUpdate(params: any) {
  return http.request(
    {
      url: Api.userUpdate,
      method: 'POST',
      params
    },
    {
      isParseToJson: true,
      isTransformRequestResult: false,
      isShowMessage: true,
      successMessageText: '修改成功',
      errorMessageText: '修改失败'
    }
  )
}

export function userUpdatePW(params: any) {
  return http.request(
    {
      url: Api.userUpdatePassword,
      method: 'POST',
      params
    },
    {
      isShowMessage: true,
      successMessageText: '修改成功',
      errorMessageText: '修改失败'
    }
  )
}

/**
 * @description: 添加用户策略
 */
export function userCreate(params: any) {
  return http.request(
    {
      url: Api.userCreate,
      method: 'POST',
      params
    },
    {
      isParseToJson: true,
      isTransformRequestResult: false,
      isShowMessage: true,
      successMessageText: '添加成功',
      errorMessageText: '添加失败'
    }
  )
}

/**
 * @description: 删除用户策略
 */
export function userDelete(params: any) {
  return http.request(
    {
      url: Api.userDelete,
      method: 'POST',
      params
    },
    {
      isTransformRequestResult: false,
      isShowMessage: true,
      successMessageText: '删除成功',
      errorMessageText: '删除失败'
    }
  )
}

/**
 * @description: 角色列表
 */
export function userList(params: any) {
  return http.request(
    {
      url: Api.userList,
      method: 'GET',
      params
    },
    {
      isTransformRequestResult: false
    }
  )
}

/**
 * @description: 角色列表
 */
export function roleList(params: any) {
  return http.request(
    {
      url: Api.roleList,
      method: 'GET',
      params
    },
    {
      isTransformRequestResult: false
    }
  )
}
